<template>
  <v-snackbar v-model="currentVal" :timeout="timeout" top :color="color">
    {{ text }}
    <v-btn icon @click="currentVal = false">
      <v-icon>mdi-delete</v-icon>
    </v-btn>
  </v-snackbar>
</template>

<script>
    /**
     * 提示消息
     * @author Canaan
     * @date 2019/8/10 17:01.
     */
    export default {
        name: 'Message',
        mounted() {
            this.$bus.$on('xy_inner_bus_message', (notice) => {
                // notice.id;
                this.currentVal = true;
                this.color = notice.type;
                this.text = notice.text;
            });
        },
        components: {},
        props: {
            value: null,
            msg: null,
            type: {
                default: 'info',
                type: String
            }
        },
        data() {
            return {
                currentVal: this.value,
                text: this.msg,
                timeout: 2000,
                color: this.type
            }
        },
        computed: {},
        methods: {},
        watch: {
            msg(val) {
                this.text = val;
            },
            type(val) {
                this.color = val;
            },
            value(val) {
                this.currentVal = val;
            },
            currentVal(val) {
                this.$emit("input", val);
            }
        },
        filters: {},
        beforeDestroy() {

        },
        destroyed() {
            this.$bus.$off('xy_inner_bus_message');
        }
    }
</script>

<style scoped>

</style>
